<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get sorting key for a string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="collator.getlocale.html">Collator::getLocale</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="collator.getstrength.html">Collator::getStrength</a></div>
 <div class="up"><a href="class.collator.html">Collator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="collator.getsortkey" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Collator::getSortKey</h1>
  <h1 class="refname">collator_get_sort_key</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.11, PECL intl &gt;= 1.0.3)</p><p class="refpurpose"><span class="refname">Collator::getSortKey</span> -- <span class="refname">collator_get_sort_key</span> &mdash; <span class="dc-title">Get sorting key for a string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-collator.getsortkey-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span> 
   <span class="methodname"><strong>Collator::getSortKey</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   )</div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> 
   <span class="methodname"><strong>collator_get_sort_key</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.collator.html" class="type Collator">Collator</a></span> <code class="parameter">$coll</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   )</div>

  <p class="para rdfs-comment">
   Return collation key for a string.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-collator.getsortkey-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">coll</code></em></dt>

     <dd>

      <p class="para">
       <a href="class.collator.html" class="classname">Collator</a> object.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">str</code></em></dt>

     <dd>

      <p class="para">
       The string to produce the key from.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-collator.getsortkey-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">Returns the collation key for the string. Collation keys can be compared directly instead of strings.</p>
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">此函数可能返回布尔值
<strong><code>FALSE</code></strong>，但也可能返回等同于 <strong><code>FALSE</code></strong> 的非布尔值。请阅读 <a href="language.types.boolean.html" class="link">布尔类型</a>章节以获取更多信息。应使用
<a href="language.operators.comparison.html" class="link">===
运算符</a>来测试此函数的返回值。</p></div>
 </div>


 <div class="refsect1 examples" id="refsect1-collator.getsortkey-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2431">
    <p><strong>Example #1 <span class="function"><strong>collator_get_sort_key()</strong></span>example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$s1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'Hello'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$coll&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_create</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'en_US'&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$res&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_get_sort_key</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$coll</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$s1</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">urlencode</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen"><br />
     71%3F%3FE%01%09%01%8F%08%00<br />
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-collator.getsortkey-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="collator.sort.html" class="function" rel="rdfs-seeAlso">collator_sort()</a> - Sort array using specified collator</span></li>
    <li class="member"><span class="function"><a href="collator.sortwithsortkeys.html" class="function" rel="rdfs-seeAlso">collator_sort_with_sort_keys()</a> - Sort array using specified collator and sort keys</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="collator.getlocale.html">Collator::getLocale</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="collator.getstrength.html">Collator::getStrength</a></div>
 <div class="up"><a href="class.collator.html">Collator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
